using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class DamageNumber : MonoBehaviour
{
    public TMP_Text damageText;
    public float lifeTime = 1.5f;
    public float lifeCounter;
    public float floatSpeed = 0.5f;

    private void  Start()
    {
        lifeCounter = lifeTime;
    }

    private void Update()
    {
        if(lifeCounter > 0){
            lifeCounter -= Time.deltaTime;
            if(lifeCounter < 0){
                Destroy(gameObject);
            }
        }
        transform.position += Vector3.up * floatSpeed * Time.deltaTime;
    }

    public void SetUpDamageNumber(int damage){
        lifeCounter = lifeTime;
        damageText.text = damage.ToString();
    }
}
